import os

# 指定第一个文件夹和第二个文件夹的路径
folder1_path = 'D:/PythonProjects/Datasets/H-Dataset/images/train'
folder2_path = 'D:/PythonProjects/Datasets/H-Dataset/labels/train'

# 获取第一个文件夹中的所有文件名（不包括后缀）
folder1_files = [os.path.splitext(file)[0] for file in os.listdir(folder1_path) if file.endswith('.jpg')]

# 获取第二个文件夹中的所有文件名（不包括后缀）
folder2_files = [os.path.splitext(file)[0] for file in os.listdir(folder2_path) if file.endswith('.txt')]

# 找出第二个文件夹中多出的txt文件
extra_txts = [file + '.txt' for file in folder2_files if file not in folder1_files]

# 找出第一个文件夹中多出的jpg文件
extra_jpgs = [file + '.jpg' for file in folder1_files if file not in folder2_files]

# 输出文件名
for file in extra_txts:
    print(file)
for file in extra_jpgs:
    print(file)